package com.ruoyi;

import com.ruoyi.common.utils.AddressUtils;
import com.ruoyi.common.utils.http.HttpClient;
import com.ruoyi.common.utils.http.LocationUtil;
import com.ruoyi.system.domain.SysDictData;
import com.ruoyi.system.utils.DictUtils;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;

import java.net.InetAddress;
import java.util.List;

/**
 * 启动程序
 * 
 * @author ruoyi
 */
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
public class RuoYiApplication
{
    public static void main(String[] args)
    {
        // System.setProperty("spring.devtools.restart.enabled", "false");
        SpringApplication.run(RuoYiApplication.class, args);
        System.out.println("(♥◠‿◠)ﾉﾞ  若依启动成功   ლ(´ڡ`ლ)ﾞ  \n" +
                " .-------.       ____     __        \n" +
                " |  _ _   \\      \\   \\   /  /    \n" +
                " | ( ' )  |       \\  _. /  '       \n" +
                " |(_ o _) /        _( )_ .'         \n" +
                " | (_,_).' __  ___(_ o _)'          \n" +
                " |  |\\ \\  |  ||   |(_,_)'         \n" +
                " |  | \\ `'   /|   `-'  /           \n" +
                " |  |  \\    /  \\      /           \n" +
                " ''-'   `'-'    `-..-'              ");
        //设置JVM代理
        List<SysDictData> jvm_proxy = DictUtils.getDictCache("jvm_proxy");
        //验证开关
        if(jvm_proxy.get(0).getDictValue().equals("1")){
            String ipAddress = jvm_proxy.get(1).getDictValue();
            String port = jvm_proxy.get(2).getDictValue();
            // http proxy
            System.setProperty("proxySet", "true");
//            System.setProperty("proxyHost", "127.0.0.1");
//            System.setProperty("proxyPort", "1080");
            System.setProperty("proxyHost", ipAddress);
            System.setProperty("proxyPort", port);
            System.setProperty("nonProxyHosts", "smtp.qq.com|127.0.0.1|server.natappfree.cc|m3958n1775.qicp.vip");

            try {
                String ip = HttpClient.doGet("http://ip.42.pl/raw");
                System.out.println("jvm公网信息："+ip);

            }catch (Exception e){
                e.printStackTrace();
            }
        }
    }
}